<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
  <meta name="description" content="">
  <meta name="author" content="ThemeBucket">
  <link rel="shortcut icon" href="#" type="image/png">

  <title>主页展示管理</title>

  <!--data table-->
  <link rel="stylesheet" href="js/data-tables/DT_bootstrap.css" />

  <link href="css/style.css" rel="stylesheet">
  <link href="css/style-responsive.css" rel="stylesheet">

  <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
  <!--[if lt IE 9]>
  <script src="js/html5shiv.js"></script>
  <script src="js/respond.min.js"></script>
  <![endif]-->
    <style>
        input[type=text]{
            width: 100%;
            padding: 12px 20px;
            margin: 8px 0;
            display: inline-block;
            border: 1px solid #ccc;
            border-radius: 4px;
            box-sizing: border-box;
        }

        input[type=button] {
            width: 100%;
            background-color: #4CAF50;
            color: white;
            padding: 14px 20px;
            margin: 8px 0;
            border: none;
            border-radius: 4px;
            cursor: pointer;
        }

        input[type=button]:hover {
            background-color: #45a049;
        }


    </style>
</head>

<body class="sticky-header">

<section>
    <!-- left side start-->
    <script src="left.js"></script>
    <!-- left side end-->
    
    <!-- main content start-->
    <div class="main-content" >

        <!-- header section start-->
        <div class="header-section">

        <!--toggle button start-->
        <a class="toggle-btn"><i class="fa fa-bars"></i></a>
        <!--toggle button end-->


        </div>
        <!-- header section end-->

        <!-- page heading start-->
        <div class="page-heading">
            <h3>
                主页展示设置
            </h3>
            <ul class="breadcrumb">
                <li>
                    <a href="#">首页</a>
                </li>
                <li>
                    <a href="#">系统信息</a>
                </li>
                <li class="active"> 主页展示设置 </li>
            </ul>
        </div>
        <!-- page heading end-->

        <!--body wrapper start-->
        <div class="wrapper">
             <div class="row">
                <div class="col-sm-12">
                <section class="panel">
                <header class="panel-heading">
                    首页展示信息修改
                    <span class="tools pull-right">
                        <a href="javascript:;" class="fa fa-chevron-down"></a>
                        <a href="javascript:;" class="fa fa-times"></a>
                     </span>
                </header>
                    <div class="panel-body">
<!--                        form表单进行修改-->
                        <form id="indexForm" style="background-color: #f2f2f2;">
                            <label for="tag" style="padding: 10px;font-size: 20px " >便签信息</label><br>
                            <textarea cols="50"  rows="3" type="text" id="tag" name="tag">内容</textarea><br>


                            <label for="notice" style="padding: 10px;font-size: 20px ">公告信息</label><br>
                            <textarea cols="50"  rows="5" type="text" id="notice" name="notice">内容</textarea><br>


                            <label for="msg" style="padding: 10px;font-size: 20px ">需要干的事情提醒</label><br>
                            <textarea cols="50"  rows="5" type="text" id="msg" name="msg">内容</textarea><br>


                            <input type="button" onclick="updateIndex()" value="点击修改">
                        </form>
                    </div>
                </section>
                </div>
                </div>
        </div>
        <!--body wrapper end-->


    </div>
    <!-- main content end-->
</section>

<!-- Placed js at the end of the document so the pages load faster -->
<script src="js/jquery-1.10.2.min.js"></script>
<script src="js/jquery-ui-1.9.2.custom.min.js"></script>
<script src="js/jquery-migrate-1.2.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/modernizr.min.js"></script>
<script src="js/jquery.nicescroll.js"></script>

<!--data table-->
<script type="text/javascript" src="js/data-tables/jquery.dataTables.js"></script>
<script type="text/javascript" src="js/data-tables/DT_bootstrap.js"></script>

<!--common scripts for all pages-->
<script src="js/scripts.js"></script>

<!--script for editable table-->
<script src="js/editable-table.js"></script>


<!--初始化权限-->
<script src="orders.js"></script>
<script>
    //序列化Json
    function getFormJson(form) {
        var o = {};
        var a = form
        $.each(a, function () {
            if (o[this.name] !== undefined) {
                if (!o[this.name].push) {
                    o[this.name] = [o[this.name]];
                }
                o[this.name].push(this.value || '');
            } else {
                o[this.name] = this.value || '';
            }
        });
        return o;
    }
    function updateIndex() {
        var serialize = $("#indexForm").serializeArray();
        var indexForm=getFormJson(serialize);
        console.log(indexForm)
        $.ajax({
            url:"/index/update",
            type:"POST",
            data: JSON.stringify(indexForm),
            contentType:"application/json;charset=UTF8",
            dataType:"json",
            success:function (res){
                alert(res.msg)
            },
            error:function (){

            }
        })
    }
    function showForm(indexBox){
        $("#tag").val(indexBox.tag)
        $("#notice").val(indexBox.notice)
        $("#msg").val(indexBox.msg)
    }
    window.onload=function (){
        var order;
        $.ajax({
            url:"/users/getOrder",
            type:"get",
            contentType:"application/json;charset=UTF8",
            dataType:"json",
            success:function (res){
                order=res;
                if(order==2){
                    order2();
                }
                if(order==3){
                    order3();
                }
            },
            error:function (){

            }
        })

        $.ajax({
            url:"/index/getMsg/1",
            type:"get",
            contentType:"application/json;charset=UTF8",
            dataType:"json",
            success:function (res){
                var indexBox=res.data
                showForm(indexBox)
            },
            error:function (){

            }
        })

    }


</script>

</body>
</html>
